package com.gaojun;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author ：gaojun
 * @date ：Created in 2022/9/26 21:51
 * @description：配置类
 * @modified By：
 * @version: 1.0$
 */
@Configuration
@ComponentScan("com.gaojun")
@MapperScan
public class AppConfig {

	@Bean
	public SqlSessionFactory sqlSessionFactory() throws IOException {
		InputStream inputStream=Resources.getResourceAsStream("mybatis.xml");
		SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
		return sqlSessionFactory;
	}

//	@Bean
//	public MapperScannerConfigurer mapperScannerConfigurer() {
//		MapperScannerConfigurer configurer=new MapperScannerConfigurer();
//		configurer.setBasePackage("com.gaojun.mapper");
//		return configurer;
//	}
}
